package view;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import util.Constantes;

import com.mysql.jdbc.Constants;

public class ViewEcolherBanco extends JFrame implements ActionListener{

	private JPanel contentPane;
	private JButton btnMySql;
	private JButton btnArrayList;

	public ViewEcolherBanco() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JPanel panel = new JPanel();
		contentPane.add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		btnMySql = new JButton("MySql");
		btnMySql.addActionListener(this);
		btnMySql.setFont(new Font("Tahoma", Font.PLAIN, 15));
		btnMySql.setBounds(138, 57, 118, 50);
		panel.add(btnMySql);
		
		btnArrayList = new JButton("ArrayList");
		btnArrayList.addActionListener(this);
		btnArrayList.setFont(new Font("Tahoma", Font.PLAIN, 15));
		btnArrayList.setBounds(138, 120, 118, 50);
		panel.add(btnArrayList);
	}

	public void actionPerformed(ActionEvent e) {
		JComponent elemento = (JComponent) e.getSource();
		if(elemento.equals(btnArrayList)){
			this.dispose();
			ViewPopularSistema view = new ViewPopularSistema();
			view.setVisible(true);
			Constantes.TIPO_BD = Constantes.ARRAY_LIST;
		}
		else if(elemento.equals(btnMySql)){
			ViewBDDados view = new ViewBDDados();
			view.setVisible(true);
			this.dispose();
			Constantes.TIPO_BD = Constantes.MYSQL;
		}
	}
}
